package com.vteba.test;

import java.util.List;
import java.util.Map;

import org.junit.Test;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

public class GenJson {

	@Test
	public void genPaper() {
		Map<String, Object> map = Maps.newHashMap();
		map.put("code", "1");
		map.put("message", "获取问卷成功");

		Map<String, Object> data = Maps.newTreeMap();
		map.put("data", data);

		// 问卷
		data.put("id", "7djask8d2js7dka");
		data.put("title", "中金通2015年风险测评问卷");
		data.put("orgId", "9jk257dj8d2js7dk1a");

		// 问题list
		List<Map<String, Object>> questionList = Lists.newArrayList();
		data.put("questionList", questionList);

		// 第一题
		Map<String, Object> questionMap = Maps.newTreeMap();

		questionList.add(questionMap);
		// 问题1
		questionMap.put("id", "a612ksd09asdjk");
		questionMap.put("title", "你有多少钱？");
		questionMap.put("no", "1");
		questionMap.put("options", false);

		List<Map<String, Object>> optionsList = Lists.newArrayList();
		questionMap.put("optionsList", optionsList);
		// 问题1选项1
		Map<String, Object> optionsMap11 = Maps.newTreeMap();
		optionsMap11.put("id", "1g003ad500s");
		optionsMap11.put("content", "500万~2000万");
		optionsMap11.put("questionId", "a612ksd09asdjk");
		optionsMap11.put("no", "A");
		optionsList.add(optionsMap11);
		// 问题1选项2
		Map<String, Object> optionsMap12 = Maps.newTreeMap();
		optionsMap12.put("id", "21g003ad500s");
		optionsMap12.put("content", "2000万~9000万");
		optionsMap12.put("questionId", "a612ksd09asdjk");
		optionsMap12.put("no", "B");
		optionsList.add(optionsMap12);
		// 问题1选项3
		Map<String, Object> optionsMap13 = Maps.newTreeMap();
		optionsMap13.put("id", "1g003ad500s");
		optionsMap13.put("content", "9000万~20000万");
		optionsMap13.put("questionId", "a612ksd09asdjk");
		optionsMap13.put("no", "C");
		optionsList.add(optionsMap13);

		// 第二题
		Map<String, Object> questionMap2 = Maps.newTreeMap();

		questionList.add(questionMap2);
		// 题目2
		questionMap2.put("id", "a612ksd09a223sdjk");
		questionMap2.put("title", "你喜欢谁？");
		questionMap2.put("no", "2");
		questionMap2.put("options", true);

		List<Map<String, Object>> optionsList2 = Lists.newArrayList();
		questionMap2.put("optionsList", optionsList2);
		// 题目2选项1
		Map<String, Object> optionsMap21 = Maps.newTreeMap();
		optionsMap21.put("id", "1g003ad500s");
		optionsMap21.put("content", "林志玲");
		optionsMap21.put("questionId", "a612ksd09a223sdjk");
		optionsMap21.put("no", "A");
		optionsList2.add(optionsMap21);

		// 题目2选项2
		Map<String, Object> optionsMap22 = Maps.newTreeMap();
		optionsMap22.put("id", "21g003ad500s");
		optionsMap22.put("content", "范冰冰");
		optionsMap22.put("questionId", "a612ksd09a223sdjk");
		optionsMap22.put("no", "B");
		optionsList2.add(optionsMap22);
		// 题目2选项3
		Map<String, Object> optionsMap23 = Maps.newTreeMap();
		optionsMap23.put("id", "1g003ad500s");
		optionsMap23.put("content", "赵丽颖");
		optionsMap23.put("questionId", "a612ksd09a223sdjk");
		optionsMap23.put("no", "C");
		optionsList2.add(optionsMap23);

		System.out.println(JSON.toJSONString(map, true));
	}

}
